package com.ecnu.common.utils.http;

import com.ecnu.common.utils.ServletUtils;

import javax.servlet.http.HttpServletRequest;

public class UrlUtils {
    public static String getUrl() {
        HttpServletRequest request = ServletUtils.getRequest();
        return getDomain(request);
    }

    public static String getDomain(HttpServletRequest request) {
        StringBuffer url = request.getRequestURL();
        String contextPath = request.getServletContext().getContextPath();
        String string = url.delete(url.length() - request.getRequestURI().length(), url.length()).append(contextPath).toString();
//        string=string.replace("http://","https://");
//        string=string+"/prod-api";
        return string;
    }
}
